/**
 * 
 */
package com.thor.palmmall.rest.sales.input.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.sales.input.ASalesTotalData;
import com.thor.palmmall.spi.sales.input.SSalesTotalData;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class ASalesTotalDataConverter implements Converter<SSalesTotalData, ASalesTotalData> {

  public static ASalesTotalDataConverter getInstance() {
    if (instance == null)
      instance = new ASalesTotalDataConverter();
    return instance;
  }

  private static ASalesTotalDataConverter instance;

  private ASalesTotalDataConverter() {
  }

  @Override
  public ASalesTotalData convert(SSalesTotalData source) {
    if (source == null) {
      return null;
    }
    ASalesTotalData target = new ASalesTotalData();
    target.setDate(source.getDate());
    target.setTotal(source.getTotal());
    target.setDetails(
        ConverterUtil.convert(source.getDetails(), ASalesInputLineConverter.getInstance()));
    return target;
  }

}
